package com.lq.ecoldchain.ui.main

import android.support.v4.app.Fragment
import com.lq.ecoldchain.base.CommonLoadingViewModel
import com.lq.ecoldchain.ui.main.introduce.IntroductionFragment
import com.lq.ecoldchain.ui.main.home.HomeFragment
import com.lq.ecoldchain.ui.main.message.MessageFragment
import com.lq.ecoldchain.ui.main.my.MineFragment
import com.lq.ecoldchain.ui.main.orderlist.OrderFragment
import org.kodein.di.Kodein
import org.kodein.di.android.ActivityRetainedScope
import org.kodein.di.android.support.AndroidLifecycleScope
import org.kodein.di.generic.*

/*
*2018/12/24 0024  18:04
*function by lq
*/
const val MAIN_MODULE_TAG = "main_module_tag"
val mainKodein  =  Kodein.Module(MAIN_MODULE_TAG) {
    bind<MainModel>() with scoped(ActivityRetainedScope).singleton {
        MainModel
    }


    bind<HomeFragment>() with scoped(ActivityRetainedScope).singleton {
        HomeFragment()
    }

    bind<MessageFragment>() with scoped(ActivityRetainedScope).singleton {
        MessageFragment()
    }

    bind<IntroductionFragment>() with scoped(ActivityRetainedScope).singleton {
        IntroductionFragment()
    }

    bind<OrderFragment>() with scoped(ActivityRetainedScope).singleton {
        OrderFragment()
    }

    bind<MineFragment>() with scoped(ActivityRetainedScope).singleton {
        MineFragment()
    }

    bind<List<Fragment>>() with scoped(ActivityRetainedScope).singleton {
        listOf(instance<HomeFragment>(),instance<MessageFragment>(),instance<IntroductionFragment>(),instance<OrderFragment>(),instance<MineFragment>())
    }


 /*   bind<FragmentViewPagerAdapter>() with scoped(ActivityRetainedScope).singleton {
        FragmentViewPagerAdapter(
                instance(),
                instance()
        )
    }*/

    bind<MainViewModel>() with scoped(ActivityRetainedScope).singleton {
        MainViewModel()
    }

    bind<MainDelegate>() with scoped(AndroidLifecycleScope).singleton {
        MainDelegate(
                mainModel = instance(),
                fragmentManager = instance(),
                fragments = instance(),
                viewModel = instance(),
                loadingViewModel = CommonLoadingViewModel.instance(context)
        )
    }
}